<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *员工管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(isset($_RQ['status'])){
		$params['status']=$_RQ['status'];
		$return['params']['status']=$_RQ['status'];
	}
	if(!empty($_RQ['nickname'])){
		$mid=pdo_getcolumn('core_members',array('uniacid'=>$_SESSION['uniacid'],'nickname like'=>'%'.$_RQ['nickname'].'%'),'id');
		$params['mid']=$mid;
		$return['params']['nickname']=$_RQ['nickname'];
	}
	if(!empty($_RQ['ordersn'])){
		$params['ordersn']=$_RQ['ordersn'];
		$return['params']['ordersn']=$_RQ['ordersn'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_vote_sendlplog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['title']=pdo_getcolumn('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['oid']),'title');
			$user=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['mid']),array('nickname','avatar','sex'));		
			$item['nickname']=$user['nickname'];
			$item['avatar']=$user['avatar'];
			$item['sex']=$user['sex'];
			$mid=pdo_getcolumn('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['oid']),'mid');
			$user=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$mid),array('nickname','avatar','sex'));		
			$item['nickname2']=$user['nickname'];
			$item['avatar2']=$user['avatar'];
			$item['sex2']=$user['sex'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'title','title'=>'参赛作品','type'=>'string'),
			array('type'=>'img_string','title'=>'送礼人','img'=>'avatar',
			'data'=>array(
				array('title'=>'','name'=>'nickname'),
				)
			),
			array('type'=>'img_string','title'=>'收礼选手','img'=>'avatar2',
			'data'=>array(
				array('title'=>'','name'=>'nickname2'),
				)
			),
			array('name'=>'fee','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'支付状态','type'=>'radio','options'=>'status'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'status','width'=>15,'title'=>'支付状态','type'=>'radio','options'=>'status'),
			array('name'=>'ordersn','width'=>15,'title'=>'订单编号','type'=>'string'),
			array('name'=>'nickname','width'=>15,'title'=>'会员昵称','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	$return['status']=array(0=>'未支付',1=>'已支付',2=>'已取消');
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_vote_sendlplog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
